﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xyz.BusinessObjects;
using Xyz.DataObjects.Interfaces;

namespace Xyz.DataObjects.Entity.Dao
{
    public class EntityPassengerDao : IPassengerDao
    {
        public void InsertPassenger(Passenger passenger)
        {
            var entity = Mapper.Map(passenger);

            using (var context = EntityObjectFactory.CreateContext())
            {
                context.PassengerEntities.AddObject(entity);
                context.SaveChanges();
            }
        }

        public List<Title> GetTitles()
        {
            using (var context = EntityObjectFactory.CreateContext())
            {
                var titles = new List<Title>();
                var query = context.TitleEntities.AsQueryable().ToList();

                query.ForEach(x => titles.Add(Mapper.Map(x)));

                return titles;
            }
        }
    }
}
